<?php
namespace app\index\controller;

use app\common\controller\Base;
use app\index\model\Logs;
use think\Config;
use think\Request;

//邮件发放任务类

class Task extends Base
{

    //use \app\index\controller\traits\CurlRequest;

    //protected $model;

    public function _initialize()
    {
        //基类授权
        //
        parent::_initialize();
        $this->model = new \app\index\model\Task();
    }

    /**
     * 发放任务列表
     */
    public function doList(Request $request)
    {
        $param = $request->param();
        
        $output = $this->model->doList($param);
        _callback($output);
    }

    /**
     * 发放任务命令
     */
    public function doIssue()
    {
        $res = $this->model->issueMailByAppointedTime();
        return json($res);
    }

    /**
     * 添加
     */
    public function add(Request $request)
    {

        $res = $this->model->doAdd($request);

        $output['data'] = $res;
        $output['success'] = $res ? true : false;
        $output['msg'] = $res ? '新增成功' : '新增失败';

        _callback($output);
    }

    /**
     * 发放任务命令
     */
    public function doCurlRequest()
    {
        $url = Config::get('remote_mail_issue');
    }

    /**
     * 通过服务器ID获取发放地址
     */
    public function getRemoteIssueUrlBySid($sid)
    {
        $url = $this->model->getRemoteIssueUrlBySid($sid);
        dump($url);
    }
}
